"""
高阶函数测试练习
"""

# sorted 测试
print(sorted([-2, -5, 1, 0, 10, -7]))
# 传入函数
print(sorted([-2, -5, 1, 0, 10, -7], key=abs))
# 排序字符串
print(sorted(['bob', 'about', 'Zoo', 'Credit'], key=str.lower))
print(sorted(['bob', 'about', 'Zoo', 'Credit'], key=str.lower, reverse=True))


# 返回函数
def lazy_function(*args):
    def sum():
        ax = 0
        for n in args:
            ax = ax + n
        return ax

    return sum


f = lazy_function(2, 2, 2, 2, 2)
print(f())
print(f)
